#!/usr/bin/ksh -x 
 
usage ()
{
echo "Enter -h for help -d directory for search -f for file which will be finded"
}

if [ -z $1 ] || [ "$1" = "-h" ] 
 then usage
 exit 0
 else
 while [ $# -gt 0 ]
  do 
  echo "$1" >> 111.txt
  shift
  done
fi

sed -n '/-d/,$p' 111.txt > directory.txt
sed -n '/-f/,$p' 111.txt > files.txt 
for DIR in `cat directory.txt`
do
 if [ -d "$DIR" ]
 then
    cd $DIR
     for FILE in `cat ~/files.txt`
     do
     if [ -f $FILE ] 
     then 
     find $DIR -name $FILE
     else
     continue
     fi
     done
    cd ..
 else
 continue
 echo "$DIR is not a directory"
 fi
done
rm 111.txt 
rm files.txt
rm directory.txt
